package cn.dglydrpy.study.ssm.service.impl;

import java.util.List;

import javax.annotation.Resource;

import org.springframework.stereotype.Service;

import cn.dglydrpy.study.ssm.dao.entity.User;
import cn.dglydrpy.study.ssm.dao.mapper.UserMapper;
import cn.dglydrpy.study.ssm.service.IUserService;

/*
 * 业务层
 */
@Service
public class UserService implements IUserService  {
	
	@Resource
	private UserMapper userMapper;

	public void addUser(User user) {
		userMapper.insert(user);
		
	}

	public void delUser(Integer id) {
		userMapper.delete(id);
		
	}

	public List<User> showAll() {
		return userMapper.selectAll();
	}

	public User showById(Integer id) {
		return userMapper.selectById(id);
	}

	public void updateUser(User user) {
		userMapper.update(user);
	}

	public User showByUsername(String username) {
		return userMapper.selectByUsername(username);
	}

	public Integer checkUserByPwd(String password) {
		return userMapper.selectCountByPassword(password);
	}

	public Integer checkByEmail(String email) {
		return userMapper.selectCountByEmail(email);
	}

	public Integer checkByPhone(String phone) {
		return userMapper.selectCountByPhone(phone);
	}

}
